package com.gitee.zhanyao.single.util.datatables;

import org.springframework.data.domain.Sort;

import java.util.ArrayList;
import java.util.List;

/**
 * Datatables 工具类
 */
public class Datatables<T> {

    /**
     * 封装返回结果给 Datatables
     *
     * @param datas           内容
     * @param recordsTotal    每页数
     * @param recordsFiltered 总数
     * @param draw            标识
     * @return Datatables 响应结果
     */
    public DataTablesResponse<T> getDataTablesResponse(List<T> datas, int recordsTotal, long recordsFiltered, int draw) {
        DataTablesResponse<T> dataTablesResponse = new DataTablesResponse<>();
        dataTablesResponse.setData(datas);
        dataTablesResponse.setRecordsTotal(recordsTotal);
        dataTablesResponse.setRecordsFiltered(recordsFiltered);
        dataTablesResponse.setDraw(draw);
        return dataTablesResponse;
    }

}
